<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="../js/vue.min.js"></script>
    <script src="../js/vue-router.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <router-link to="/a">t1</router-link>
      <router-link to="/b">t2</router-link>
      <router-view name="v1"></router-view>
      <router-view name="v2"></router-view>
    </div>
    <script>
      // 模板一
      const t11 = {
        template: `<div style="width:400px;height:200px;border:blue 1px solid">11</div>`,
      };
      const t12 = {
        template: `<div style="width:400px;height:200px;background:pink">12</div>`,
      };
      // 模板二
      const t21 = {
        template: `<div style="width:400px;height:200px;border:red 1px solid">21</div>`,
      };
      const t22 = {
        template: `<div style="width:400px;height:200px;background:yellow">22</div>`,
      };
      // 配置路由
      const router = new VueRouter({
        routes: [
          {
            path: "/a",
            components: {
              v1: t11,
              v2: t12,
            },
          },
          {
            path: "/b",
            components: {
              v1: t21,
              v2: t22,
            },
          },
        ],
      });
      var vue = new Vue({
        el: "#app",
        router: router,
      });
    </script>
  </body>
</html>
